package miningexplorerproject.vue;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.Toolkit;

import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

@SuppressWarnings("serial")
public class vuePrincipale extends JFrame {

	private JPanel panPrincipal;
	private JPanel panForm;
	private JPanel panCheckingStatus;
	private JPanel panCreditHistory;
	private JPanel panSavingStatus;
	private JPanel panForeignWorker;
	private JPanel panHousing;
	private JPanel panOtherPaymentPlan;
	private JPanel panPurpose;
	private JPanel panButton;
	
	private JLabel labCheckingStatus;
	private JLabel labCreditHistory;	
	private JLabel labSavingStatus;
	private JLabel labForeignWorker;
	private JLabel labHousing;
	private JLabel labOtherPaymentPlan;
	private JLabel labPurpose;
		
	private JButton btValider;
	
	private JComboBox chekingStatus;
	private JComboBox creditHistory;
	private JComboBox savingStatus;
	private JComboBox foreignWorker;
	private JComboBox housing;
	private JComboBox otherPaymentPlan;
	private JComboBox purpose;

	public vuePrincipale(){
		super("Renseignez les informations sur le client");
		setLayout(new BorderLayout());
		Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
 		this.setSize((int)d.getWidth()-50,(int)d.getHeight()-100);
 		this.setLocation(5,5);
		
		setResizable(true);
		setDefaultCloseOperation(EXIT_ON_CLOSE);

		ListenerPrincipal ls = new ListenerPrincipal(this);
		
		panPrincipal = new JPanel(new GridLayout(2, 1));
		
		panForm = new JPanel(new GridLayout(7, 1));
		
		panCheckingStatus = new JPanel(new GridLayout(1, 2));
		panCreditHistory = new JPanel(new GridLayout(1, 2));
		panSavingStatus = new JPanel(new GridLayout(1, 2));
		panForeignWorker = new JPanel(new GridLayout(1, 2));
		panHousing = new JPanel(new GridLayout(1, 2));
		panOtherPaymentPlan = new JPanel(new GridLayout(1, 2));
		panPurpose = new JPanel(new GridLayout(1, 2));		
		
		panButton = new JPanel(new FlowLayout());
		
		labCheckingStatus = new JLabel("Checking status");
		labCheckingStatus.setFont(new Font("Arial", Font.BOLD, 16));
	
		labCreditHistory = new JLabel("Credit history");
		labCreditHistory.setFont(new Font("Arial", Font.BOLD, 16));
	
		labSavingStatus = new JLabel("Saving status");
		labSavingStatus.setFont(new Font("Arial", Font.BOLD, 16));
			
		labForeignWorker = new JLabel("Foreign worker");
		labForeignWorker.setFont(new Font("Arial", Font.BOLD, 16));
			
		labHousing = new JLabel("Housing");
		labHousing.setFont(new Font("Arial", Font.BOLD, 16));
		
		labOtherPaymentPlan = new JLabel("Other payment plan");
		labOtherPaymentPlan.setFont(new Font("Arial", Font.BOLD, 16));
		
		labPurpose = new JLabel("Purpose");
		labPurpose.setFont(new Font("Arial", Font.BOLD, 16));
	

		String[] checkingStatusList = { "<0", "0<=X<200", ">=200", "no checking"};
		chekingStatus = new JComboBox(checkingStatusList);
		chekingStatus.addActionListener(ls);
		chekingStatus.setActionCommand("checkingStatus");
		chekingStatus.setSelectedIndex(0);
		
		String[] creditHistoryList = { "no credits/all paid", "all paid", "existing paid", "delayed previously", "critical/other existing credit"};
		creditHistory = new JComboBox(creditHistoryList);
		creditHistory.addActionListener(ls);
		creditHistory.setActionCommand("creditHistory");
		creditHistory.setSelectedIndex(0);
		
		String[] savingStatusList = { "<100", "100<=X<500", "500<=X<1000", ">=1000", "no known savings"};
		savingStatus = new JComboBox(savingStatusList);
		savingStatus.addActionListener(ls);
		savingStatus.setActionCommand("savingStatus");
		savingStatus.setSelectedIndex(0);
		
		String[] foreignWorkerList = { "yes","no"};
		foreignWorker = new JComboBox(foreignWorkerList);
		foreignWorker.addActionListener(ls);
		foreignWorker.setActionCommand("foreignWorker");
		foreignWorker.setSelectedIndex(0);
		
		String[] housingList = { "rent", "own", "for free"};
		housing = new JComboBox(housingList);
		housing.addActionListener(ls);
		housing.setActionCommand("housing");
		housing.setSelectedIndex(0);
		
		String[] otherPaymentPlanList = { "bank", "stores", "none"};
		otherPaymentPlan = new JComboBox(otherPaymentPlanList);
		otherPaymentPlan.addActionListener(ls);
		otherPaymentPlan.setActionCommand("otherPaymentPlan");
		otherPaymentPlan.setSelectedIndex(0);
		
		String[] purposeList = { "new car", "furniture/equipment", "radio/tv", "repairs", "education", "vacation", "retraining", "business", "other","domestic appliance","used car"};
		purpose = new JComboBox(purposeList);
		purpose.addActionListener(ls);
		purpose.setActionCommand("purpose");
		purpose.setSelectedIndex(0);
		
		btValider = new JButton("Validate");
		btValider.setActionCommand("Validate");
		btValider.addActionListener(ls);
	
		panCheckingStatus.add(labCheckingStatus);
		panCheckingStatus.add(chekingStatus);

		panCreditHistory.add(labCreditHistory);
		panCreditHistory.add(creditHistory);
		
		panSavingStatus.add(labSavingStatus);
		panSavingStatus.add(savingStatus);
		
		panForeignWorker.add(labForeignWorker);
		panForeignWorker.add(foreignWorker);
		
		panHousing.add(labHousing);
		panHousing.add(housing);
		
		panOtherPaymentPlan.add(labOtherPaymentPlan);
		panOtherPaymentPlan.add(otherPaymentPlan);
		
		panPurpose.add(labPurpose);
		panPurpose.add(purpose);
		
		panForm.add(panCheckingStatus);
		panForm.add(panCreditHistory);
		panForm.add(panSavingStatus);
		panForm.add(panForeignWorker);
		panForm.add(panHousing);
		panForm.add(panOtherPaymentPlan);
		panForm.add(panPurpose);
		
		panButton.add(btValider);

		panPrincipal.add(panForm);
		panPrincipal.add(panButton);
		
		this.add(panPrincipal);
		setVisible(true);
	}
	
	public JComboBox getChekingStatus() {
		return chekingStatus;
	}

	public void setChekingStatus(JComboBox chekingStatus) {
		this.chekingStatus = chekingStatus;
	}

	public JComboBox getCreditHistory() {
		return creditHistory;
	}

	public void setCreditHistory(JComboBox creditHistory) {
		this.creditHistory = creditHistory;
	}

	public JComboBox getSavingStatus() {
		return savingStatus;
	}

	public void setSavingStatus(JComboBox savingStatus) {
		this.savingStatus = savingStatus;
	}

	public JComboBox getForeignWorker() {
		return foreignWorker;
	}

	public void setForeignWorker(JComboBox foreignWorker) {
		this.foreignWorker = foreignWorker;
	}

	public JComboBox getHousing() {
		return housing;
	}

	public void setHousing(JComboBox housing) {
		this.housing = housing;
	}

	public JComboBox getOtherPaymentPlan() {
		return otherPaymentPlan;
	}

	public void setOtherPaymentPlan(JComboBox otherPaymentPlan) {
		this.otherPaymentPlan = otherPaymentPlan;
	}

	public JComboBox getPurpose() {
		return purpose;
	}

	public void setOtherParties(JComboBox purpose) {
		this.purpose = purpose;
	}
}
